//Συνδεση του PriceList με τη βαση δεδομενων μεσω του javaconnect2
package DAO;

import Exceptions.DaoException;
import Models.PriceList;
import Interfaces.IPriceList_Dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class PriceList_Dao implements IPriceList_Dao {


    @Override
    public PriceList insertPricelist(String storename, String fmpoukali, String fpoto, String fmpyra, String fsfinaki, String fmiso, String kmpoukali, String kpoto, String kmpyra, String ksfinaki, String kmiso) throws DaoException {
         Connection conn = null;
        PreparedStatement pst = null;
        conn = javaconnect2.connectDB();

        try {
            String query = "INSERT INTO prices (storename, fmpoukali , fpoto , fmpyra , fsfinaki , fmiso , kmpoukali , kpoto, kmpyra, ksfinaki , kmiso ) value (?,?,?,?,?,?,?,?,?,?,?)";
            pst = conn.prepareStatement(query);
            pst.setString(1, storename);
            pst.setString(2, fmpoukali);
            pst.setString(3, fpoto);
            pst.setString(4, fmpyra);
            pst.setString(5, fsfinaki);
            pst.setString(6, fmiso);
            pst.setString(7, kmpoukali);
            pst.setString(8, kpoto);
            pst.setString(9, kmpyra);
            pst.setString(10, ksfinaki);
            pst.setString(11, kmiso);

            pst.execute();
            pst.close();
            conn.close();
        } catch (SQLException e) {
            throw new IllegalArgumentException("Error in PriceList_Dao");
        }
        return null;
    }
}
